package com.hzhr.iot.core.dto;

import com.hzhr.iot.core.responseCode.BaseResponseCodeEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

@ApiModel(value = "BaseResponseDto", description = "响应模型")
public class BaseResponseDto<T> {
    @ApiModelProperty(value = "响应码", required = true)
    private String code;
    @ApiModelProperty(value = "响应码描述", required = true)
    private String message;
    @ApiModelProperty(value = "响应体")
    private T data;

    public BaseResponseDto() {
        this.code = "0";
        this.message = "成功";
        this.data = null;
    }

    public BaseResponseDto(String code, String message) {
        this.code = code;
        this.message = message;
        this.data = null;
    }

    public BaseResponseDto(BaseResponseCodeEnum responseCodeEnum) {
        this.code = responseCodeEnum.getCode();
        this.message = responseCodeEnum.getMessage();
        this.data = null;
    }

    public BaseResponseDto(String code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public BaseResponseDto(T data) {
        this.code = "0";
        this.message = "成功";
        this.data = data;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
